package com.ysh.smartplatform.mapper;

import com.ysh.smartplatform.pojo.SysUserOnline;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 袁胜虎 on 2022/9/6 11:17
 */
public interface OnLineUserMapper {

    @Insert("INSERT INTO  sys_user_online values (#{sessionId},#{loginName},#{ipaddr},#{loginLocation},#{browser},#{os},#{status},#{startTimestamp},#{lastAccessTime},#{expireTime})")
    void addOnlineData(SysUserOnline sysUserOnline);

    @Select("SELECT login_name FROM sys_user_online WHERE login_name=#{login_name}")
    String dataExist(String loginName);

    @Update("update sys_user_online set sessionId=#{sessionId},ipaddr=#{ipaddr},login_location=#{loginLocation},browser=#{browser},os=#{os},status=#{status},start_timestamp=#{startTimestamp},last_access_time=#{lastAccessTime},expire_time=#{expireTime} WHERE login_name =#{loginName}")
    void updateOnlineData(SysUserOnline sysUserOnline);

    @Delete("delete from sys_user_online where login_name = #{loginName}")
    void deleteOnline(String loginName);
}
